#ifndef DIALOGCONFIG_H
#define DIALOGCONFIG_H

#include <QtGui>
#include "controls/rotatingdialog.h"

class FTPushButton;
class FTLabel;
class OauthManager;
class FTWidgetList;
class FTCheckBox;
class FTRadioButton;
class FTTabWidget;
class FTLineEdit;
class FTTextArea;

class DialogConfig : public RotatingDialog
{
    Q_OBJECT
public:
    explicit DialogConfig();
    ~DialogConfig();

private slots:
    void accept();

    // Slots for the general page
    void savePositionChanged(bool);
    void confirmInternetChanged(bool);
    void alwaysOnChanged(bool);
    void altitudeCorrectionChanged(QString);
    void driveClicked();
    void gpsAutostartChanged(bool);
    void coordFormatChanged(int);
    void showAdsChanged(bool);
    void useSatsOnlyChanged(bool);

    // Slots for the tracking page
    void trackModeSelected(QAbstractButton*);
    void trackTimeChanged();
    void trackDistanceChanged();
    void AutosaveChanged(bool);
    void calculateSpeedChanged(bool);
    void minimumDopChanged();

    // Slots for the breadcrumbs page
    void breadcrumbsChanged();
    void breadcrumbsSetpin();

    // Slots for the waypoints page
    void drawWaypointsChanged(bool);
    void drawWaypointsIconChanged(bool);
    void drawWaypointsNameChanged(bool);
    void navigationProximityChanged(QString);

    // Slots for the language page
    void langSelected(QAbstractButton*);

    // Slots for the maps page
    void showMapsSelected(bool);

private:

    FTTabWidget* content;
    void buildGeneralPage();
    void buildTrackingPage();
    void buildBreadcrumbsPage();
    void buildWaypointsPage();
    void buildLanguagePage();

    // The close button will be on the main tabs page
    FTPushButton* closeButton;


    // The "general" settings page
    QWidget* general_page;
    FTLabel* general_label;
    // Save map position widget
    FTCheckBox* saveposition;
    // statr gps automatically on startup
    FTCheckBox* gpsautostart;
    // Enable "light always on"
    FTCheckBox* always_on;
    // Show ads
    FTCheckBox* show_ads;
    // Storage drive
    FTPushButton* drive_select;
    FTLabel* drive_label;
    // Confirm internet connections
    FTCheckBox* internet_confirm;
    // Use only datellites?
    FTCheckBox* use_sats_only;


    // The "tracking settings" page
    QWidget* tracking_page;
    FTLabel* tracking_label;
    // Autosave livetrack
    FTCheckBox* autosave;
    // Enable speed calculations
    FTCheckBox* calc_speed;
    // Tracking mode widgets
    FTLabel* trackModeLabel;
    QButtonGroup track_mode;
    FTRadioButton* auto_track;
    FTRadioButton* time_track;
    FTRadioButton* space_track;
    FTLineEdit* time_val_track;
    FTLineEdit* space_val_track;
    FTLabel* time_label;
    FTLabel* space_label;
    FTLabel* minimumDopLabel;
    FTLineEdit* minimumDop;
    // altitude correction
    FTLabel* altitude_correction_label;
    FTLineEdit* altitude;


    // The www.gobreadcrumbs.com page
    QWidget* breadcrumbs_page;
    FTLabel* breadcrumbs_label;
    FTPushButton* breadcrumbs_authorize;
    FTPushButton* breadcrumbs_setpin;
    FTLineEdit* breadcrumbs_pin;
    OauthManager* breadcrumbs_oauth;
    void breadcrumbsLayout();
    bool breadcrumbs_pin_requested;


    // Waypoint settings page
    QWidget* waypoints_page;
    FTLabel* waypoints_label;
    FTCheckBox* draw_waypoints;
    FTCheckBox* draw_waypoints_name;
    FTCheckBox* draw_waypoints_icon;
    FTLabel* navigationProximityLabel;
    FTLineEdit* navigationProximityEdit;
    // Degrees format
    FTLabel* coordFormatLabel;
    QButtonGroup coordFormat;
    FTRadioButton* coordFormatDec;
    FTRadioButton* coordFormatDms;
    FTRadioButton* coordFormatDm;
    FTRadioButton* coordFormatUtm;
    // Maps
    FTCheckBox* show_maps;


    // Language "page"
    FTTextArea* languageLabel;
    QWidget* language_page;
    FTWidgetList* lang_widget;
    QButtonGroup langs;
    QHash<FTRadioButton*, QString> lang_buttons;


    QLayout* createHorizontal();
    QLayout* createVertical();
};


#endif // DIALOGCONFIG_H
